<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>动态管理</title>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">
    <%@include file="../../include/commonFile.jsp" %>
    <style type="text/css">
        .c-time-list-content .detail {
            width: 100% !important;
        }

        .bg-avater-big {
            width: 150px;
            height: 120px;
            display: inline-block;
            background-size: cover;
            background-repeat: no-repeat;
            background-position: center;
            position: relative;
            border: #fff 2px solid;
            border-radius: 4px;
        }

        .info-container .member-logo {
            margin-bottom: 0;
            position: relative;
        }

        .vip-big {
            position: absolute;
            right: -6px;
            bottom: 0px;
            background-color: #fff;
            display: block;
            width: 16px;
            height: 16px;
            text-align: center;
            border-radius: 50%;
            color: #e8473f;
        }

        .vip-big .vip-big-font {
            font-size: 16px;
            position: absolute;
            color: #e8473f;
            top: 50%;
            left: 50%;
            -webkit-transform: translate(-50%, -47%);
            transform: translate(-50%, -47%);
        }

        .veritcal-center {
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            -webkit-transform: translate(-50%, -50%);
        }

        .avater-big {
            width: 40px;
            height: 40px;
            display: inline-block;
            background-size: cover;
            background-repeat: no-repeat;
            background-position: center;
            border-radius: 50%;
            position: relative;
            border: #fff 2px solid;
        }

        .huangguan-big {
            font-size: 16px !important;
            color: #ffc107 !important;
        }
    </style>
</head>
<body>
<!--头部-->
<%@include file="../../include/header.jsp" %>
<div class="index-outside">
    <%@include file="../../include/sidebar.jsp" %>
    <!--内容-->
    <section>
        <div class="section-main">

            <div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
                <div class="layui-tab-content">
                    <form class="layui-form" action="${ctx}/member/moment/list.do" id="myForm" method="post">
                        <input type="hidden" name="pageNo" id="pageNo"/>
                        <input type="hidden" name="partentId" value="${partentId}"/>
                        <div class="f-search-bar">
                            <div class="search-container">
                                <ul class="search-form-content">
                                    <li class="form-item-inline">
                                        <label class="search-form-lable">动态类型</label>
                                        <div class="layui-input-inline">
                                            <select name="momentType">
                                                <option value="">全部</option>
                                                <c:forEach var="momentType" items="${momentTypes}">
                                                    <option value="${momentType.key}" ${momentType.key== moment.momentType ? 'selected="selected"' : ''}>${momentType.value}</option>
                                                </c:forEach>
                                            </select>
                                        </div>
                                    </li>
                                    <c:if test="${isXzgsAdmin || !isChild}">
                                        <li class="form-item-inline"><label class="search-form-lable">发布机构</label>
                                            <div class="layui-input-inline">
                                                <select name="memberGroupId">
                                                    <option value="">全部</option>
                                                    <c:forEach var="memberGroup" items="${memberGroupList}">
                                                        <option value="${memberGroup.id}" ${moment.memberGroupId == memberGroup.id ? 'selected="selected"' : ''}>${memberGroup.realname}</option>
                                                    </c:forEach>
                                                </select>
                                            </div>
                                        </li>
                                    </c:if>
                                    <li class="form-item-inline"><label class="search-form-lable">个人发布者</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="memberName" autocomplete="off" class="layui-input"
                                                   value="${moment.memberName}" placeholder="请输入查询个人发布者">
                                        </div>
                                    </li>
                                    <li class="form-item-inline"><label class="search-form-lable">内容</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="content" autocomplete="off" class="layui-input"
                                                   value="${moment.content}" placeholder="请输入查询动态内容">
                                        </div>
                                    </li>
                                </ul>
                                <ul class="search-form-content">
                                    <li class="form-item"><label class="search-form-lable">发布时间</label>
                                        <div class="check-btn-inner" id="timeType">
                                            <a id="all" href="javascript:void(0);"
                                               onclick="setTimeType($(this),0,'#myForm')" ${empty input.timeType || input.timeType == 0 ? 'class="active"' : ''}>全部</a>
                                            <a href="javascript:void(0);"
                                               onclick="setTimeType($(this),1,'#myForm')" ${input.timeType == 1 ? 'class="active"' : ''}>今天</a>
                                            <a href="javascript:void(0);"
                                               onclick="setTimeType($(this),2,'#myForm')" ${input.timeType == 2 ? 'class="active"' : ''}>本周内</a>
                                            <a href="javascript:void(0);"
                                               onclick="setTimeType($(this),3,'#myForm')" ${input.timeType == 3 ? 'class="active"' : ''}>本月内</a>
                                            <input type="hidden" name="timeType" value="${input.timeType}"/>
                                        </div>
                                        <div class="layui-inline">
                                            <div class="layui-input-inline">
                                                <input class="layui-input" type="text" name="createStart"
                                                       value="${empty input.createStart ? '' : fn:substring(input.createStart, 0, 10)}"
                                                       placeholder="开始日">
                                            </div>
                                            -
                                            <div class="layui-input-inline">
                                                <input class="layui-input" type="text" name="createEnd"
                                                       value="${empty input.createEnd ? '' : fn:substring(input.createEnd, 0, 10)}"
                                                       placeholder="截止日">
                                            </div>
                                        </div>
                                    </li>
                                    <li class="form-item-inline">
                                        <div class="sub-btns">
                                            <a class="layui-btn layui-btn-danger"
                                               href="javascript:submitFunction('#myForm')">查询</a>
                                            <a class="layui-btn layui-btn-normal"
                                               href="javascript:resetFunction('#myForm')">重置</a>
                                        </div>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </form>
                    <div class="c-time-list-content">
                        <ul id="view">
                            <c:if test="${page.totalCount == 0}">
                                <div class="f16 tc mt15">还没有动态，赶紧发布一个吧</div>
                            </c:if>
                            <c:forEach var="cMoment" items="${cMoments}">
                                <li>
                                    <div class="detail-content">
                                        <div class="detail">
                                            <div class="act-title">
                                                <div class="user-infos l">
                                                    <div class="avater-big l common-img" id="logo">
                                                        <img src="${cMoment.memberLogo}?imageMogr2/auto-orient/thumbnail/!50p"
                                                             alt="" onerror="txz.errImg(this)"
                                                             onload="txz.imgLoad(this)">
                                                    </div>
                                                    <div class="l pt10 ml5"><span
                                                            class="f16">${cMoment.memberName}</span></div>
                                                    <div class="cl"></div>
                                                </div>
                                                <span class="status f16" style="height: 44px;line-height: 44px;">
                                                 &nbsp;&nbsp; / &nbsp; <fmt:formatDate value="${cMoment.createDate}"
                                                                                       pattern="yyyy-MM-dd HH:mm"/>
                                                </span>
                                                <span class="status f16" style="height: 44px;line-height: 44px;">
                                                <c:choose>
                                                    <c:when test="${cMoment.momentType == 0}">
                                                        <span class="status f18 red">系统通知</span>
                                                    </c:when>
                                                    <c:when test="${cMoment.momentType == 1}">
                                                        <span class="status f18 red">新会员加入</span>
                                                    </c:when>
                                                    <c:when test="${cMoment.momentType == 2}">
                                                        <span class="status f18 red">活动发布</span>
                                                    </c:when>
                                                    <c:when test="${cMoment.momentType == 3}">
                                                        <span class="status f18 red">圈子话题</span>
                                                    </c:when>
                                                    <c:when test="${cMoment.momentType == 4}">
                                                        <span class="status f18 red">相册上传</span>
                                                    </c:when>
                                                    <c:when test="${cMoment.momentType == 5}">
                                                        <span class="status f18 red">批量添加积分</span>
                                                    </c:when>
                                                    <c:when test="${cMoment.momentType == 6}">
                                                        <span class="status f18 red">文章</span>
                                                    </c:when>
                                                </c:choose>
                                                </span>
                                                <div class="cl"></div>
                                            </div>
                                            <div class="act-title f16">
                                                    ${cMoment.content}
                                            </div>
                                            <div class="act-title">
                                                <c:forEach var="pic" items="${cMoment.picList}">
                                                    <div class="bg-avater-big common-img"
                                                         style="background-image: url('${pic}'),url(${ctx}/image/img_bg.png)">
                                                        <img src="${pic}" alt="" onerror="txz.errImg(this)"
                                                             onload="txz.imgLoad(this)">
                                                    </div>
                                                </c:forEach>
                                                <c:if test="${cMoment.dataType == 2}">
                                                    <video src="${cMoment.multimediaUrl}"
                                                           class="bg-avater-big common-img"
                                                           style="width: 250px; height: 160px;" controls="controls">
                                                    </video>
                                                </c:if>
                                                <c:forEach var="member" items="${cMoment.members}">
                                                    <div class="avater-big l common-img" id="logo"
                                                         style="width: 30px;height: 30px">
                                                        <img src="${member.logo}?imageMogr2/auto-orient/thumbnail/!30p"
                                                             alt="" onerror="txz.errImg(this)"
                                                             onload="txz.imgLoad(this)">
                                                    </div>
                                                </c:forEach>
                                            </div>
                                            <div class="opts-btns tb-opts" style="width:475px">
                                                <div class="comm-opts">
                                                    <c:if test="${(isXzgsAdmin)||(!isChild || cMoment.createBy == memberId)}">
                                                        <a href="${ctx}/member/moment/form.do?id=${cMoment.id}">
                                                            <i class="iconfont icon-edit btn-icon"></i> 编辑</a>
                                                        <a href="javascript:txz.deleteObject('确定要删除该动态么？', '${ctx}/member/moment/delete.do?id=${cMoment.id}');">
                                                            <i class="iconfont icon-delete btn-icon"></i> 删除
                                                        </a>
                                                        <c:if test="${cMoment.isTop == 1}">
                                                            <a href="javascript:cancleTop('${cMoment.id}')"> <i
                                                                    class="iconfont icon-upblock btn-icon"></i>
                                                                取消置顶
                                                            </a>
                                                        </c:if>
                                                        <c:if test="${cMoment.isTop == 0}">
                                                            <a href="javascript:toTop('${cMoment.id}')"> <i
                                                                    class="iconfont icon-top btn-icon"></i>
                                                                置顶
                                                            </a>
                                                        </c:if>
                                                        <c:if test="${isXzgsAdmin || !isChild}">
                                                            <c:if test="${cMoment.isDisplayAll == 1}">
                                                                <a href="javascript:cancleglobal('${cMoment.id}')"> <i
                                                                        class="iconfont icon-upblock btn-icon"></i>
                                                                    取消全局可见
                                                                </a>
                                                            </c:if>
                                                            <c:if test="${cMoment.isDisplayAll == 0}">
                                                                <a href="javascript:toglobal('${cMoment.id}')"> <i
                                                                        class="iconfont icon-top btn-icon"></i>
                                                                    设为全局可见
                                                                </a>
                                                            </c:if>
                                                        </c:if>
                                                    </c:if>

                                                </div>
                                            </div>
                                            <div class="act-title red">
                                                    ${cMoment.announcerOrg}
                                            </div>
                                        </div>
                                    </div>
                                </li>
                            </c:forEach>
                        </ul>
                    </div>
                    <div id="page_content" class="page-container"></div>
                </div>
            </div>
        </div><!--底部-->
        <%@include file="../../include/footer.jsp" %>
    </section>
</div>

<script type="text/javascript" src="${ctx}/script/common/list.js"></script>
<script type="text/javascript" src="${ctx}/script/common/table_option.js"></script>
<script type="text/javascript">
    $(function () {
        //加载分页
        loadPageNew({
            elem: 'page_content',
            totalCount: '${page.totalCount}',
            limit: '${page.limit}',
            page: '${page.page}'
        });

        layui.use(['laydate'], function () {
            var laydate = layui.laydate;
            // 查询发布日期
            var start = {
                elem: 'input[name=createStart]'
            };
            var end = {
                elem: 'input[name=createEnd]'
            };
            laydate.render(start);
            laydate.render(end);
        });
    })

    //置顶
    function toTop(id) {
        var url = '${ctx}/member/moment/topOperating.do?id=' + id + "&sign=1";
        $.post(url, {}, function (data) {
            if (data.success == true) {
                util.layerAlertSuccess("设置成功", function () {
                    window.location.reload();
                })
            } else {
                util.layerMsgError("设置失败")
            }
        });
    }

    //取消置顶
    function cancleTop(id) {
        var url = '${ctx}/member/moment/topOperating.do?id=' + id + "&sign=0";
        $.post(url, {}, function (data) {
            if (data.success == true) {
                util.layerAlertSuccess("设置成功", function () {
                    window.location.reload();
                })
            } else {
                util.layerMsgError("设置失败")
            }
        });
    }


    //全局可见
    function toglobal(id) {
        var url = '${ctx}/member/moment/globalOperating.do?id=' + id + "&sign=1";
        $.post(url, {}, function (data) {
            if (data.success == true) {
                util.layerAlertSuccess("设置成功", function () {
                    window.location.reload();
                })
            } else {
                util.layerMsgError("设置失败")
            }
        });
    }

    //取消全局可见
    function cancleglobal(id) {
        var url = '${ctx}/member/moment/globalOperating.do?id=' + id + "&sign=0";
        $.post(url, {}, function (data) {
            if (data.success == true) {
                util.layerAlertSuccess("设置成功", function () {
                    window.location.reload();
                })
            } else {
                util.layerMsgError("设置失败")
            }
        });
    }
</script>
<script type="text/javascript">
    txz.initHeader({
        nav: [{
            name: '动态管理',
            curr: true
        }],
        info: '<span class="f12">共<b id="totalCount">${page.totalCount}</b>条记录</span>'
        , btns: [{
            name: '发布动态',
            icon: 'add',
            href: '${ctx}/member/moment/form.do',
            isCheckExpire: true
        }]
    });
</script>
</body>
</html>